<template>
  <el-dialog title="新增标签"
  :visible.sync="visible">
  <el-form @keyup.enter.native="labelNameSubmit()" label-width="80px">
    <el-form-item label="标签名称">
      <el-input v-model="labelName" placeholder="标签名称"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="labelNameSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
    return {
      visible: false,
      labelName:""
    }
  },
  methods: {
    init () {
      this.visible = true
    },
    labelNameSubmit(){
      this.visible = false
            this.$http({
              url: this.$http.adornUrl('/disk/label/add'),
              method: 'post',
              data: this.$http.adornData({
                'labelName':this.labelName
              })
            }).then(({data}) => {
              if (data && data.code === 200) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshLabelList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>